<?php
require_once('mysql_connect.php');
if ($_SESSION['admin'] == 1){
}else{
	header("Location:login.php");
	exit();
}

$loc ="admin";


if(isset($_POST['submit'])){
	$name = escape_data($_POST['name']);
	$query = "INSERT INTO genre(name) VALUES('". $name ."')";
	$result = mysql_query($query);
}
if(isset($_POST['id'])){
	$name = escape_data($_POST['name']);
	$query = "UPDATE genre SET name='" . $name . "' WHERE id=" . $_POST['id'];
	$result = mysql_query($query);
}

$pullquery = "SELECT * FROM genre";
$pullresult = mysql_query($pullquery);
include('top.php');
?>
<TABLE><TR><TD>
<?php
while($pullrow = mysql_fetch_array($pullresult)){
?>
<BR><FORM ACTION="genre.php" method="post"><INPUt type="hidden" id="id" name="id" value="<?php echo $pullrow['id'];?>"><FONT FACE="Verdana" size=-1>name: </FONT><INPUT genre="TEXT" name="name" id="name" value="<?php echo unescape_data($pullrow['name']);?>"><INPUT type="submit" name="sub" id="sub" value="rename genre"></FONT></FORM>
<?php
}
?>
<BR><HR width="100%">
<FORM ACTION="genre.php" method="post"><BR><FONT FACE="Verdana" size=-1>name: </FONT><INPUT genre="TEXT" name="name" id="name"><INPUT type="submit" name="submit" id="submit" value="add genre"></FONT></FORM>
</TD></TR></TABLE>
<?php
include('bot.php');
?>